{include file="kuyou/common/menu" /}
<form id="edit-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <input id="c-purchase_code" class="form-control" name="row[purchase_code]" type="hidden" value="{$row.purchase_code}">
    <input id="c-chase_code" class="form-control" name="row[chase_code]" type="hidden" value="{$row.chase_code}">
    <input id="c-code_type" class="form-control" name="row[code_type]" type="hidden" value="{$row.code_type}">
    <div style="position: relative;">
        {if condition="$row.examine_status==1 && isset($set['examine']['is_checked']) && $set['examine']['is_checked']==1"}
        <div id="mark" class="has-audit"></div>
        {/if}
        <div class="list" style="overflow-x: auto">
            <table id="purchase_table">
                <tr>
                    <th>
                        <span class="must">*</span>
                        {:__('commodity')}
                    </th>
                    <th>{:__('Goods_note')}</th><th class="goods_attr_sd">{:__('Goods_attr')}</th><th>{:__('Goods_unit')}</th><th>{:__('Stores_id')}</th>
                    <th>{:__('batch')}</th><th>{:__('date of manufacture')}</th><th>{:__('quality guarantee period')}({:__('day')})</th><th>{:__('Valid until')}</th>
                    <th>{:__('Production quantity')}</th><th>{:__('Number')}</th><th>{:__('Default_unit')}</th><th>{:__('Basic_nmber')}</th><th>{:__('Unit_price')}</th><th>{:__('All_money')}</th>
                    <th>{:__('Remark')}</th>
                </tr>
                <tr style="display: none;">
                    <td>
                        <div class="goods_code_box">
                            <input type="hidden" name="row[goods_code][]" class="goods_code">
                            <span class="goods_code_span"><img src="__CDN__/assets/addons/kuyou/img/more.png"></span>
                            <input type="text" class="ipt goods_name">
                        </div>
                    </td>
                    <td><div><input type="text" name="row[goods_note][]" class="goods_note" readonly></div></td>
                    <td class="goods_attr_sd">
                        <div>
                            <select name="row[goods_attr][]" class="form-control goods_attr">
                                <option value=""></option>
                            </select>
                        </div>
                    </td>
                    <td>
                        <div>
                            <select name="row[goods_unit][]" class="form-control goods_unit">
                                <option value=""></option>
                            </select>
                        </div>
                    </td>
                    <td>
                        <div>
                            <select name="row[stores_id][]" class="form-control stores_id">
                                <option value=""></option>
                                {foreach name="storesList" item="vo"}
                                <option value="{$vo.id}">{$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </td>
                    <td>
                        <div>
                            <div class="batch_div">
                                <input name="row[batch][]" class="batch_sec"><input type="hidden" name="row[batch_id][]" class="batch_id">
                                <span class="batch_span"><img src="__CDN__/assets/addons/kuyou/img/more.png"></span>
                            </div>
                        </div>
                    </td>
                    <td><div><input type="text" class="ipt manufacture" name="row[manufacture][]"></div></td>
                    <td><div><input type="text" class="ipt guarantee" name="row[guarantee][]"></div></td>
                    <td><div><input type="text" class="ipt validity" name="row[validity][]"></div></td>
                    <td><div><input type="number" readonly name="row[need_number][]" class="need_number number_decimal" value=""></div></td>
                    <td><div><input type="number" name="row[number][]" class="number number_decimal number_decimal"><input type="hidden" class="period_period" name="row[period_period][]"></div></td>
                    <td><div><input type="text" readonly class="default_unit"><input type="hidden" name="row[default_unit][]" class="default_unit_id"></div></td>
                    <td><div><input type="text" name="row[basic_nmber][]" class="basic_nmber number_decimal" readonly></div></td>
                    <td><div><input type="number" name="row[unit_price][]" class="unit_price price_decimal"></div></td>
                    <td><div><input type="number" name="row[all_money][]" class="all_money price_decimal"></div></td>
                    <td><div><input type="text" name="row[remark][]" class="remark"></div></td>
                </tr>
                {foreach name="purchase_info" item="info" key="k"}
                <tr>
                    <td>
                        <div class="goods_code_box">
                            {foreach name="goodsList" item="vo"}
                            {if condition="$vo.goods_code==$info.goods_code"}{php}$shelf_life = $vo['shelf_life'];{/php}
                            <input type="hidden" name="row[goods_code][]" class="goods_code" value="{$vo.goods_code}">
                            <input type="text" readonly class="ipt goods_name" value="{$vo.goods_code} {$vo.goods_name}">
                            {/if}
                            {/foreach}
                        </div>
                    </td>
                    <td><div><input type="text" name="row[goods_note][]" class="goods_note" value="{$info.goods_note|htmlentities}" readonly></div></td>
                    <td class="goods_attr_sd">
                        <div>
                            <select name="row[goods_attr][]" class="form-control goods_attr">
                                <option value=""></option>
                                {foreach name="info.unit.attr" item="vo"}
                                <option value="{$vo.id}" {if condition="$vo.id==$info.goods_attr"}selected{/if}>{$vo.attr_name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </td>
                    <td>
                        <div>
                            <select name="row[goods_unit][]" class="form-control goods_unit">
                                <option value=""></option>
                                {foreach name="info.unit.unit" item="vo"}
                                {if condition="$vo.id==$info.default_unit"}{php}$unit_name=$vo['name'];{/php}{/if}
                                <option value="{$vo.id}" {if condition="$vo.id==$info.unit_id"}selected{/if}>{$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </td>
                    <td>
                        <div>
                            <select name="row[stores_id][]" class="form-control stores_id">
                                <option value=""></option>
                                {foreach name="storesLists" item="vo"}
                                <option value="{$vo.id}" {if condition="$vo.id==$info.stores_id"}selected{/if}>{$vo.name}</option>
                                {/foreach}
                            </select>
                        </div>
                    </td>
                    <td>
                        <div>
                            <div class="batch_div">
                                <input name="row[batch][]" class="batch_sec" value="{$info.batch_name|default=''}">
                                <input type="hidden" value="{$info.batch_id|default=''}" name="row[batch_id][]" class="batch_id">
                                <span class="batch_span" data-id="2"><img src="__CDN__/assets/addons/kuyou/img/more.png"></span>
                            </div>
                        </div>
                    </td>
                    <td><div><input type="text" class="ipt manufacture" name="row[manufacture][]" value="{if condition="!empty($info['manufacture'])"}{$info.manufacture|date='Y-m-d',###}{/if}"></div></td>
                    <td><div><input type="text" class="ipt guarantee" name="row[guarantee][]" value="{if condition="!empty($info['manufacture'])"}{$info.guarantee|htmlentities}{/if}"></div></td>
                    <td><div><input type="text" class="ipt validity" name="row[validity][]" value="{if condition="!empty($info['validity'])"}{$info.validity|date='Y-m-d',###}{/if}"></div></td>
                    <td><div><input type="number" readonly name="row[need_number][]" class="need_number number_decimal" value="{$info.need_number|htmlentities}"></div></td>
                    <td><div><input type="number" name="row[number][]" value="{$info.number|htmlentities}" class="number number_ipt number_decimal"><input type="hidden" class="period_period" name="row[period_period][]" value='{$info.period|default=""}'></div></td>
                    <td><div><input type="text" readonly class="default_unit" value="{$unit_name|default=''}"><input type="hidden" value="{$info.default_unit|htmlentities}" name="row[default_unit][]" class="default_unit_id"></div></td>
                    <td><div><input type="text" name="row[basic_nmber][]" class="basic_nmber number_decimal" value="{$info.basic_nmber|htmlentities}" readonly></div></td>
                    <td><div><input type="number" name="row[unit_price][]" class="unit_price price_decimal" value="{$info.purchase|htmlentities}"></div></td>
                    <td><div><input type="number" name="row[all_money][]" class="all_money price_decimal" value="{$info.money|htmlentities}"></div></td>
                    <td><div><input type="text" name="row[remark][]" class="remark" value="{$info.remark|htmlentities}"></div></td>
                </tr>
                {/foreach}
                {php}for($a=0;$a<(4-sizeof($purchase_info));$a++){ {/php}
                <tr>
                    <td>
                        <div class="goods_code_box">
                            <input type="hidden" name="row[goods_code][]" class="goods_code">
                            <input type="text" class="ipt goods_name">
                        </div>
                    </td>
                    <td><div><input type="text" name="row[goods_note][]" class="goods_note" readonly></div></td>
                    <td class="goods_attr_sd"><input type="hidden" name="row[goods_attr][]" class="goods_attr"></td>
                    <td><input type="hidden" name="row[goods_unit][]" class="goods_unit"></td>
                    <td><input type="hidden" name="row[stores_id][]" class="stores_id"></td>
                    <td><input type="hidden" name="row[batch_id][]" class="batch_id"></td>
                    <td><div><input type="text" class="ipt manufacture" name="row[manufacture][]" value=""></div></td>
                    <td><div><input type="text" class="ipt guarantee" name="row[guarantee][]" value=""></div></td>
                    <td><div><input type="text" class="ipt validity" name="row[validity][]" value=""></div></td>
                    <td><div><input type="number" readonly name="row[need_number][]" class="need_number number_decimal" value=""></div></td>
                    <td><div><input type="number" name="row[number][]" class="number number_decimal number_ipt"><input type="hidden" class="period_period" name="row[period_period][]"></div></td>
                    <td><div><input type="text" readonly class="default_unit"><input type="hidden" name="row[default_unit][]" class="default_unit_id"></div></td>
                    <td><div><input type="text" name="row[basic_nmber][]" class="basic_nmber number_decimal" readonly></div></td>
                    <td><div><input type="number" name="row[unit_price][]" class="unit_price price_decimal"></div></td>
                    <td><div><input type="number" name="row[all_money][]" class="all_money price_decimal"></div></td>
                    <td><div><input type="text" name="row[remark][]" class="remark"></div></td>
                </tr>
                {php}}{/php}
            </table>
        </div>
    </div>
    <div class="chose_goods_boxs"></div>

    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-primary btn-embossed disabled">{:__('OK')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>
